package com.wk.springframework.beans;

import com.wk.springframework.beans.PropertyValue;

import java.util.List;

public class PropertyValues {
    private List<PropertyValue> propertyValueList = new java.util.ArrayList<>();

    public void addPropertyValue(PropertyValue value) {
        this.propertyValueList.add(value);
    }

    public PropertyValue[] getPropertyValueList() {
        return this.propertyValueList.toArray(new PropertyValue[0]);
    }

    public PropertyValue getPropertyValue(String propertyName) {
        for (PropertyValue pv : this.propertyValueList) {
            if (pv.getName().equals(propertyName)) {
                return pv;
            }
        }
        return null;
    }

    public void addPropertyValue(String propertyName, Object value) {
        PropertyValue pv = new PropertyValue(propertyName, value);
        this.addPropertyValue(pv);
    }
}
